package com.gao.spring.service.impl;

import com.gao.spring.service.BookService;
import com.gao.spring.service.CheckoutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Projectname SSM
 * @Filename CheckoutServiceImpl
 * @Author an
 * @Data 2022/8/3 11:22
 * @Description TODO
 */
public class CheckoutServiceImpl implements CheckoutService {

    @Autowired
    private BookService bookService;

    @Override
    @Transactional
    public void checkOut(Integer userId, Integer[] bookIds) {

        for (Integer bookId : bookIds) {
            bookService.buyBook(userId,bookId);
        }
    }
}
